package by.semerikov.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import by.semerikov.constants.Results;
import by.semerikov.exceptions.ConnectorException;
import by.semerikov.exceptions.DAOException;
import by.semerikov.model.Person;
import by.semerikov.model.Proposal;
import by.semerikov.service.ProposalService;
import by.semerikov.service.ServiceFactory;

public class ReadMyProposalAction extends SecuredAction {

	@Override
	public ActionForward executedInternal(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response, Person user) throws DAOException, ConnectorException {
		// Create object proposal from form
		Proposal newProposal = new Proposal(null, null, null, null, null, null,
				null, user);

		ProposalService proposalService = ServiceFactory.getInstance()
				.getProposalService();
			List<Proposal> result = proposalService.getProposal(newProposal);
			request.setAttribute("trips", result);
		
		return mapping.findForward(Results.SUCCESS);

	}
}
